package com.dmw.mapper;

import com.dmw.Entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper{


    @Select("SELECT * FROM user WHERE username = #{username}")
    User getByUsername(String username);

    @Insert("INSERT INTO user (username, password, role, status, create_time, update_time) " +
            "VALUES (#{username}, #{password}, #{role}, #{status}, now(), now())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(User user);

    @Select("select * from user where id = #{userId}")
    User getByUserId(Long userId);
}
